package cn.iocoder.yudao.module.crossborder.platform.dal.mysql.platformapilog;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crossborder.platform.dal.dataobject.platformapilog.PlatformApiLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crossborder.platform.controller.admin.platformapilog.vo.*;

/**
 * 跨境电商平台API调用日志 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface PlatformApiLogMapper extends BaseMapperX<PlatformApiLogDO> {

    default PageResult<PlatformApiLogDO> selectPage(PlatformApiLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlatformApiLogDO>()
                .eqIfPresent(PlatformApiLogDO::getPlatformId, reqVO.getPlatformId())
                .eqIfPresent(PlatformApiLogDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(PlatformApiLogDO::getApiConfigId, reqVO.getApiConfigId())
                .eqIfPresent(PlatformApiLogDO::getSyncTaskId, reqVO.getSyncTaskId())
                .eqIfPresent(PlatformApiLogDO::getTraceId, reqVO.getTraceId())
                .eqIfPresent(PlatformApiLogDO::getApiType, reqVO.getApiType())
                .likeIfPresent(PlatformApiLogDO::getApiName, reqVO.getApiName())
                .eqIfPresent(PlatformApiLogDO::getApiEndpoint, reqVO.getApiEndpoint())
                .eqIfPresent(PlatformApiLogDO::getHttpMethod, reqVO.getHttpMethod())
                .eqIfPresent(PlatformApiLogDO::getRequestHeaders, reqVO.getRequestHeaders())
                .eqIfPresent(PlatformApiLogDO::getRequestParams, reqVO.getRequestParams())
                .eqIfPresent(PlatformApiLogDO::getRequestBody, reqVO.getRequestBody())
                .eqIfPresent(PlatformApiLogDO::getResponseStatus, reqVO.getResponseStatus())
                .eqIfPresent(PlatformApiLogDO::getResponseHeaders, reqVO.getResponseHeaders())
                .eqIfPresent(PlatformApiLogDO::getResponseBody, reqVO.getResponseBody())
                .betweenIfPresent(PlatformApiLogDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(PlatformApiLogDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(PlatformApiLogDO::getDuration, reqVO.getDuration())
                .eqIfPresent(PlatformApiLogDO::getSuccess, reqVO.getSuccess())
                .eqIfPresent(PlatformApiLogDO::getErrorCode, reqVO.getErrorCode())
                .eqIfPresent(PlatformApiLogDO::getErrorMsg, reqVO.getErrorMsg())
                .eqIfPresent(PlatformApiLogDO::getRetryCount, reqVO.getRetryCount())
                .eqIfPresent(PlatformApiLogDO::getUserIp, reqVO.getUserIp())
                .eqIfPresent(PlatformApiLogDO::getUserAgent, reqVO.getUserAgent())
                .betweenIfPresent(PlatformApiLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PlatformApiLogDO::getId));
    }

}